package com.health;

public class LongTermMedicalCareInsurance {

    public String applicant;
    public double insuredAmount;
    public int issueAge;

    public LongTermMedicalCareInsurance(String applicant,
                                        double insuredAmount, int issueAge){
        this.applicant = applicant;
        this.insuredAmount = insuredAmount;
        this.issueAge = issueAge;
    }

    public String printPolicy() {

        StringBuilder output = new StringBuilder();

        if (issueAge >= 20){
            double expenses = insuredAmount + (issueAge - 20) * insuredAmount;

            // print headers
            output.append("======Printing Policy======\n");
            output.append("Product: ").append("Long Term Medical Care Insurance").append('\n');
            output.append("Applicant: ").append(applicant).append('\n');
            output.append("Insured Amount: ").append(insuredAmount).append('\n');
            output.append("Issue Age: ").append(issueAge).append('\n');
            output.append("Expenses: ").append(expenses).append('\n');
            output.append("======Printing End=========\n");

        } else{
            output.append("年龄不符合投保规则，不能投保");
        }

        return output.toString();
    }

}
